/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clks.shattered;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author 10135228
 */
public class drawPanel extends JPanel{

    static final long serialVersionUID =80312L;
    JFrame myFrame;
    BufferedImage[] picArray;
    BufferedImage currentImage;
    public drawPanel(BufferedImage onePic){
        this(new BufferedImage[]{onePic});
    }
    
    public drawPanel(BufferedImage[] picArray) {
        super();
        if(picArray==null) return;
        this.picArray = picArray;
        myFrame = new JFrame("Preview");
        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        myFrame.setContentPane(this);
        myFrame.setVisible(true);
        myFrame.setSize(picArray[0].getWidth()*8+myFrame.getInsets().left*2,picArray[0].getHeight()*8+myFrame.getInsets().top+myFrame.getInsets().bottom);
        for (int i = 0; i < picArray.length; i++) {
            currentImage = picArray[i];
            repaint();            
            try {
                Thread.sleep(3000);
            } catch (InterruptedException ex) {
                Logger.getLogger(drawPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
            
        }
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2 =(Graphics2D)g;
        g2.scale(8, 8);
        g2.drawImage(currentImage, 0, 0, null);   
    }
    
}
